import { ApiProperty } from "@nestjs/swagger";
import { $Enums, User } from "@prisma/client";
import { Decimal } from "@prisma/client/runtime/library";

import { jwtConstants } from "@/core/auth/constants";

export class LoginVo implements Omit<User, "createdAt" | "updatedAt" | "deletedAt" | "password"> {
    @ApiProperty()
    id: number;
    @ApiProperty()
    username: string;
    @ApiProperty()
    avatar: string;
    @ApiProperty()
    email: string;
    @ApiProperty()
    token: string;
    @ApiProperty()
    token_expiration: number;

    sn: string;
    realname: string;
    @ApiProperty()
    nickname: string;
    mobile: string;
    money: Decimal;
    totalRechargeAmount: Decimal;
    @ApiProperty()
    gender: $Enums.Gender;
    channel: $Enums.Channel;
    isDisabled: boolean;
    isDeleted: boolean;
    isNew: boolean;
    lastLoginIp: string;
    lastLoginAt: Date;

    constructor(user: User, token: string) {
        this.id = user.id;
        this.username = user.username;
        this.nickname = user.nickname;
        this.email = user.email;
        this.avatar = user.avatar;
        this.gender = user.gender;
        this.token = token;
        this.token_expiration = Date.now() + jwtConstants.expiresIn * 1000;
    }
    title: string;
    style: string;
    address: string;
    website: string;
    weibo: string;
}
